
// pages/user/bill/putForward/newPassword/newPassword.js
import{
  setUp_pay_password
} from "../../../../../api.js"
var app =getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    ispassword: true,
    Length2: 6, 
    Length1: 6, 
    bank_input_bind_num: 0,
    focus_input:true,
    password:'',
    isFocus1: true,
    isFocus2: false,
    Value1:"",
    Value2: "",
    allmany_num:""
  },
  colse() {
    this.setData({
      bank_alert: true
    })
  },
  formSubmit(e) {
    this.setData({
      showpay: false
    })
    console.log(e.detail);
    setUp_pay_password({
      token: app.globalData.token,
      password:this.data.Value1,
      repassword:this.data.Value2
    }).then(res => {
      console.log(res)
      if (res.data.code == 666) {
        wx.showToast({
          title: res.data.msg,
          icon:"none"
        })
        setTimeout(function () {
          wx.redirectTo({
            url: '/pages/user/bill/bill'
          })
        }, 1500)
      } else {
        wx.showToast({
          title: res.data.msg,
          icon: 'none'
        })
      }
    })
  },  

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  bank_input_bind: function (e) {
    var num = e.detail.value;
    var that = this
    that.setData({
      bank_input_bind_num: num.length
    })
    if (num.length > 5) {
      that.setData({
        focus_input: false,
        password: num
      })
    }
  },
  Focusa(e) {
    var that = this;
    console.log(e.detail.value);
    var inputValue = e.detail.value;
    that.setData({
      Value1: inputValue,
    })
  },
  Focusb(e) {
    var that = this;
    console.log(e.detail.value);
    var inputValue = e.detail.value;
    that.setData({
      Value2: inputValue,
    })
  },
  input_foc: function () {
    this.setData({
      focus_input: true
    })
  },
  Tap1() {
    var that = this;
    that.setData({
      isFocus2: false,
      isFocus1: true
      
    })
  },
  Tap2() {
    var that = this;
    that.setData({
      isFocus1: false,
      isFocus2: true
      
    })
  },
  confirmpassword:function(){
    var password = this.data.password
    if(password.length == 6){
      wx.navigateTo({
        url: '/pages/user/bill/putForward/confirmPassword/confirmPassword?password=' + password,
        success: function(res) {},
        fail: function(res) {},
        complete: function(res) {},
      })
    }else{
      wx.showToast({
        title: '请输入6为数字密码',
        icon:'none'
      })
    }
  }
})